home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.5)
-
- __version__ = '1.0'
- __title__ = 'HPLIP Installer'
- __doc__ = 'Installer for HPLIP tarball.'
- import getopt
- import os
- import os.path as os
- import sys
- from base.g import *
- from base import utils
- from installer import core
- USAGE = [
- (__doc__, '', 'name', True),
- ('Usage: sh ./hplip-install [MODE] [OPTIONS]', '', 'summary', True),
- utils.USAGE_SPACE,
- ('[MODE]', '', 'header', False),
- ('Run in interactive mode:', '-i or --interactive (Default)', 'option', False),
- utils.USAGE_SPACE,
- utils.USAGE_OPTIONS,
- ('Automatic mode (chooses the most common options):', '-a or --auto', 'option', False),
- utils.USAGE_LOGGING1,
- utils.USAGE_LOGGING2,
- utils.USAGE_LOGGING3,
- utils.USAGE_HELP,
- utils.USAGE_SPACE,
- utils.USAGE_NOTES]
-
- def usage(typ = 'text'):
- if typ == 'text':
- utils.log_title(__title__, __version__)
-
- utils.format_text(USAGE, typ, __title__, 'hplip-install', __version__)
- sys.exit(0)
-
- log.set_module('hplip-install')
- log.debug('euid = %d' % os.geteuid())
- mode = INTERACTIVE_MODE
- auto = False
-
- try:
- (opts, args) = getopt.getopt(sys.argv[1:], 'hl:guiaw', [
- 'help',
- 'help-rest',
- 'help-man',
- 'help-desc',
- 'logging=',
- 'interactive',
- 'auto',
- 'web',
- 'browser'])
- except getopt.GetoptError:
- usage()
- sys.exit(1)
-
- if os.getenv('HPLIP_DEBUG'):
- log.set_level('debug')
-
- for o, a in opts:
- if o in ('-h', '--help'):
- usage()
- continue
- if o == '--help-rest':
- usage('rest')
- continue
- if o == '--help-man':
- usage('man')
- continue
- if o == '--help-desc':
- print __doc__,
- sys.exit(0)
- continue
- if o in ('-l', '--logging'):
- log_level = a.lower().strip()
- if not log.set_level(log_level):
- usage()
-
- log.set_level(log_level)
- if o == '-g':
- log.set_level('debug')
- continue
- if o in ('-i', '--interactive'):
- mode = INTERACTIVE_MODE
- continue
- if o in ('-a', '--auto'):
- auto = True
- continue
- if o in ('-w', '--browser', '--web'):
- mode = BROWSER_MODE
- continue
-
- log_file = os.path.normpath('./install.log')
- if os.path.exists(log_file):
- os.remove(log_file)
-
- log.set_logfile(log_file)
- log.set_where(log.LOG_TO_CONSOLE_AND_FILE)
- log.debug('Log file=%s' % log_file)
- (version_description, version_public, version_internal) = core.getHPLIPVersion()
- log.debug('HPLIP Description=%s Public version=%s Internal version = %s' % (version_description, version_public, version_internal))
- prop.version = version_public
- utils.log_title(__title__, __version__)
- if mode == BROWSER_MODE:
- from installer import web_install
- log.debug('Starting web browser installer...')
- web_install.start()
- elif mode == INTERACTIVE_MODE:
- from installer import text_install
- log.debug('Starting text installer...')
- text_install.start(auto)
- else:
- log.error("Invalid mode. Please use '-i' or '-w' to select the mode.")
- sys.exit(1)
-